//
//  sectionHeadView.m
//  HappyBug
//
//  Created by liulei on 2018/12/21.
//  Copyright © 2018年 www.hc.com.cn. All rights reserved.
//

#import "sectionHeadView.h"
#define Height  [UIScreen mainScreen].bounds.size.height
#define Width   [UIScreen mainScreen].bounds.size.width
@implementation sectionHeadView{
    
    
}

-(instancetype)initWithFrame:(CGRect)frame{
    
    self=[super initWithFrame:frame];
    if(self){
        [self initView];
    }
    
    return self;
}
//init整体执行之后 执行  
- (void)layoutSubviews{
    NSLog(@"layoutSubviews");
    self.frame=CGRectMake(0, 0, Width, 80);
    self.headselectimage.frame=CGRectMake(self.headselectbt.frame.origin.x+self.headselectbt.frame.size.width+10,self.frame.size.height*0.5-14, 28, 28);
    self.headselectlabel.frame=CGRectMake(self.headselectbt.frame.size.width+self.headselectbt.frame.origin.x+10, 0, Width-(self.headselectimage.frame.origin.x+self.headselectimage.frame.size.width+20), self.frame.size.height);
    
}
-(void)initView{
    self.backgroundColor=[UIColor greenColor];
    self.headselectbt =[[UIButton alloc]initWithFrame:CGRectMake(10,self.frame.size.height*0.5-10, 32, 32)];
    [self.headselectbt addTarget:self action:@selector(checkclick:) forControlEvents:UIControlEventTouchUpInside];
    [self.headselectbt setBackgroundImage:[UIImage imageNamed:@"list_unchoose"] forState:UIControlStateNormal];
    [self addSubview:self.headselectbt];
    
    
    self.headselectimage =[[UIImageView alloc]init];
    [self.headselectimage setImage:[UIImage imageNamed:@"shopImage"]];
    [self addSubview:self.headselectimage];
    
    self.headselectlabel =[[UILabel alloc]init];
    self.headselectlabel.text=@"李宁官方旗舰店（五道口店）";
    [self.headselectlabel setFont:[UIFont systemFontOfSize:16]];
    self.headselectlabel.textAlignment=NSTextAlignmentCenter;
    [self addSubview:self.headselectlabel];
    
    
}
-(void)checkclick:(UIButton *)sender{
    //控制 单选按钮
    sender.selected = !sender.selected;
    
    if(sender.isSelected){
        [self.headselectbt setBackgroundImage:[UIImage imageNamed:@"list_choose"] forState:UIControlStateNormal];
    }else{
        [self.headselectbt setBackgroundImage:[UIImage imageNamed:@"list_unchoose"] forState:UIControlStateNormal];
        
    }
    
}
@end
